#
# CMakeLists.txt - CMake configuration file for swmm/outfile
#
# Created: July 11, 2019
#
# Author: Michael E. Tryby
#         US EPA ORD/CESER
#

# configure file groups
set(SWMM_OUT_PUBLIC_HEADERS
    include/swmm_output.h
    include/swmm_output_enums.h
    include/swmm_output_export.h
    )
set(INCLUDE_DIST "include")
set(TOOL_DIST "bin")
set(LIBRARY_DIST "bin")
set(CONFIG_DIST "cmake")

# the binary output file API
set(LIBNAME swmmoutputapi)
add_library(${LIBNAME}
    SHARED
        swmm_output.c
        errormanager.c
    )

target_include_directories(${LIBNAME}
    PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
        $<INSTALL_INTERFACE:${INCLUDE_DIST}>
    )

include(GenerateExportHeader)
generate_export_header(${LIBNAME}
    BASE_NAME swmm_output
    EXPORT_MACRO_NAME EXPORT_OUT_API
    EXPORT_FILE_NAME swmm_output_export.h
    STATIC_DEFINE SHARED_EXPORTS_BUILT_AS_STATIC
    )

file(COPY ${CMAKE_CURRENT_BINARY_DIR}/swmm_output_export.h
    DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/include
    )


install(TARGETS ${LIBNAME} EXPORT swmmoutputapiTargets
    RUNTIME    DESTINATION "${TOOL_DIST}"
    LIBRARY    DESTINATION "${TOOL_DIST}"
    ARCHIVE    DESTINATION "${LIBRARY_DIST}"
    FRAMEWORK  DESTINATION "${TOOL_DIST}"
    )

install(
    EXPORT
        swmmoutputapiTargets
    DESTINATION
        "${CONFIG_DIST}"
    FILE
        swmmoutputapi-config.cmake
    )

install(FILES ${SWMM_OUT_PUBLIC_HEADERS} DESTINATION "${INCLUDE_DIST}")
